﻿@model Model.Database.Power
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <title>编辑用户</title>
    <link href="~/Content/Scripts/bootstrap-3.3.5-dist/css/bootstrap.min.css" rel="stylesheet" />

    <style>
        body {
            overflow-x: hidden;
        }

        .table {
            width: 90%;
            margin: 0 auto;
            margin-top: 10px;
            margin-bottom: 10px;
            text-align: center;
        }

        .leftTd {
            width: 30%;
            font-weight: bold;
        }

        .rightTd {
            width: 70%;
        }

        textarea {
            resize: none;
        }
    </style>
    <!--引入脚本解决兼容性(hack技术，必须放入head中)-->
    <!--[if lt IE 9]>
        <script src="~/Content/Scripts/html5_css3/html5shiv.min.js"></script>
        <script src="~/Content/Scripts/html5_css3/respond.min.js"></script>
        <script src="~/Content/Scripts/PIE-2.0beta1/PIE_IE678.js"></script>
    <![endif]-->
</head>
<body>
    <form id="form1" method="post">
        <table class="table table-bordered table-hover table-condensed">
            <tr>
                <td class="leftTd">权限Id</td>
                <td class="rightTd">
                    <input type="text" id="powerID" name="PowerId" value="@Model.PowerId" readonly class="form-control" placeholder="权限Id" />
                </td>
            </tr>
            <tr>
                <td class="leftTd">菜单名称</td>
                <td class="rightTd">
                    <input type="text" id="powerName" name="PowerName" value="@Model.PowerName" class="form-control" placeholder="菜单名称" />
                </td>
            </tr>
            <tr>
                <td class="leftTd">请求路径</td>
                <td class="rightTd">
                    <input type="text" id="url" name="Url" value="@Model.Url" class="form-control" placeholder="请求路径" />
                </td>
            </tr>
            <tr>
                <td class="leftTd">请求方式</td>
                <td class="rightTd">
                    <select name="IsPost" class="form-control">
                        @{
                            if (Model.IsPost)
                            {
                                <option value=true>Post</option>
                                <option value=false>Get</option>
                            }
                            else
                            {
                                <option value=false>Get</option>
                                <option value=true>Post</option>
                            }
                        }
                    </select>
                </td>
            </tr>
            <tr>
                <td class="leftTd">菜单/按钮</td>
                <td class="rightTd">
                    <select id="isMenu" name="IsMenu" class="form-control">
                        @{
                            if (Model.IsMenu)
                            {
                                <option value=true>菜单</option>
                                <option value=false>按钮</option>
                            }
                            else
                            {
                                <option value=false>按钮</option>
                                <option value=true>菜单</option>
                            }
                        }
                    </select>
                </td>
            </tr>
            <tr>
                <td class="leftTd">菜单图标</td>
                <td class="rightTd">
                    <input type="text" id="menuIcon" name="MenuIcon" value="@Model.MenuIcon" class="form-control" placeholder="菜单图标" />
                </td>
            </tr>
            <tr>
                <td class="leftTd">Controller名称</td>
                <td class="rightTd">
                    <input type="text" id="controllerName" name="ControllerName" value="@Model.ControllerName" class="form-control" placeholder="Controller名称" />
                </td>
            </tr>
            <tr>
                <td class="leftTd">Action名称</td>
                <td class="rightTd">
                    <input type="text" id="actionName" name="ActionName" value="@Model.ActionName" class="form-control" placeholder="Action名称" />
                </td>
            </tr>
            <tr>
                <td class="leftTd">描述</td>
                <td class="rightTd">
                    <textarea rows="3" id="description" name="Description" class="form-control" placeholder="描述">@Model.Description</textarea>
                </td>
            </tr>
            <tr>
                <td class="leftTd">排序号</td>
                <td class="rightTd">
                    <input type="text" id="sort" name="Sort" value="@Model.Sort" class="form-control" placeholder="排序号" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <button id="submitBtn" type="submit" class="btn btn-success" style="margin-right: 20px;">保存</button>
                    <button type="reset" class="btn btn-danger" style="margin-left: 20px;">重置</button>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
<script src="~/Content/Scripts/jquery-2.0.3.min.js"></script>
<script src="~/Content/Scripts/layer/2.1/layer.js"></script>
<script>
    var iframeIndex = parent.layer.getFrameIndex(window.name); //获取窗口索引

    $(function () {
        $("#submitBtn").click(function () {
            var item = this;
            if ($("#powerName").val().trim() == "" || $("#sort").val().trim() == "") {
                layer.msg("请填写必要信息", { icon: 2, time: 2000 });
            }
            else {
                $(item).attr("disabled", "disabled");
                $.ajax({
                    url: "/Power/Manager/EditSubmit",
                    type: "post",
                    data: $("#form1").serialize(),
                    dataType: "json",
                    success: function (data) {
                        if (data.Pass) {
                            parent.table1.ajax.reload(null, false);
                            parent.layer.msg(data.Msg, { icon: 1, time: 2000 });
                            parent.layer.close(iframeIndex);
                        }
                        else {
                            layer.msg(data.Msg, { icon: 2, time: 2000 });
                            $(item).removeAttr("disabled");
                        }
                    },
                    error: function (msg) {
                        layer.msg(msg.status, { icon: 2, time: 2000 });
                    }
                });
            }

            return false;
        });
    });
</script>